package com.tanhua.dubbo.api;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.tanhua.domain.db.User;
import com.tanhua.dubbo.mapper.UserMapper;
import org.apache.dubbo.config.annotation.Service;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.Date;

@Service
public class UserApiImpl implements UserApi {
    @Autowired
    private UserMapper userMapper;
    @Override
    public long save(User user) {

        userMapper.insert(user);
        return user.getId();
    }

    @Override
    public User findByMobile(String mobile) {
        QueryWrapper<User> wrapper = new QueryWrapper<>();
        wrapper.eq("mobile", mobile);
        return userMapper.selectOne(wrapper);
    }
    @Override
    public void update(User user) {
        userMapper.updateById(user);
    }

    @Override
    public User findById(Integer userId) {
        return userMapper.selectById(userId);
    }

}
